package cn.exrick.xboot.modules.masterdata.call;


import cn.exrick.xboot.modules.masterdata.server.sendData.IMdmSubscribe;
import cn.exrick.xboot.modules.masterdata.server.sendData.MdmSubscribeServiceLocator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.transaction.Transactional;

@Slf4j
@RestController
@Api(description = "")
@RequestMapping("/xboot/CallMasterSendData")
@Transactional
public class CallMasterSendDataController {
    @RequestMapping(value = "/sendData", method = RequestMethod.POST)
    @ApiOperation(value = "sendData")
    public String sendData() {
        String data=null;
        try {
            MdmSubscribeServiceLocator locator = new MdmSubscribeServiceLocator();
            IMdmSubscribe mdmSubscribeServicePort = locator.getMdmSubscribeServicePort();
            data = mdmSubscribeServicePort.sendDataStates("PORTAL", sendDataXML());
            System.out.println(data);

        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return data;
    }

    public static String sendDataXML( ){
        String soapXML="<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                +"<sendData> "
                +"<taskId>95EB2092D540EAB6FAD0982A3449C956</taskId>"
                +"<datas>"
                +"<data tableName=\"MD_MIDSTAFF\">"
                +"<createUnit>--</createUnit>"
                +"<recid>6EAFE23E60000041CC04112B0D56C13C</recid>"
                +"<version>7975842222622900321</version>"
                +"<sendDetail>11111</sendDetail>"
                +"<sendState>1</sendState> "
                +"</data>"
                +"</datas>"
                +"</sendData>";
        return soapXML;
    }

    /*public static void main(String[] argv) {
        try {
            MdmSubscribeServiceLocator locator = new MdmSubscribeServiceLocator();
            //MdmSubscribeServiceSoapBindingStub m = new MdmSubscribeServiceSoapBindingStub();
            IMdmSubscribe mdmSubscribeServicePort = locator.getMdmSubscribeServicePort();
            String data = mdmSubscribeServicePort.getData("PORTAL", getDataXML());
            System.out.println(data);

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }*/


}
